package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.text.TextField;
	
	import utils.GameServer;
	import utils.debug.Console;
	import utils.map.IResizeDisplayObject;
	import utils.map.MapContainer;
	import utils.map.MapLoaderInterface;
	import utils.map.MapManager;
	import utils.map.PathServer;
	import utils.pool.ConstPool;
	import utils.role.Hero;
	
	public class EngineAS3 extends Sprite
	{
		private var mapServer:MapManager;
		private var mapContainer:MapContainer;
		private var debugContainer:Sprite;
		private var hero:Hero;
		
		private var gameServer:GameServer 
		
		public function EngineAS3()
		{
			this.addEventListener(Event.ADDED_TO_STAGE,addToStage);
		}
		private function addToStage(event:Event):void{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			gameServer = new GameServer(stage);
			gameServer.addEventListener(Event.COMPLETE,gameStart);
			gameServer.start();
		}
		
		private function gameStart(e:Event):void{
			stage.addEventListener(Event.RESIZE,onStageResize);
			onStageResize();
			stage.addChild(Console.getInstance());
			gameServer.gotoScence("CJ301");
		}
		
		private function onStageResize(event:Event = null):void{
			for(var i:int;i<stage.numChildren;i++){
				var obj:Object = stage.getChildAt(i);
				if(obj is IResizeDisplayObject){
					obj.resize(); 
				}
			}
			gameServer.resize();
		}
		
	}
}